//
//  ConfirmOrderCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/21.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "ConfirmOrderCell.h"

@implementation ConfirmOrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle: style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{

    
    self.orderImg = [[UIImageView alloc] init];
    _orderImg.image = [UIImage imageNamed:@"headgao.jpg"];
    [self.contentView addSubview:_orderImg];
    
    self.orderPrice = [[UILabel alloc] init];
    _orderPrice.font = [UIFont systemFontOfSize:13];
    _orderPrice.font = [UIFont boldSystemFontOfSize:13];
    _orderPrice.textColor = DEFAULT_COLOR;
    _orderPrice.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderPrice];
    
    
    self.orderNumber = [[UILabel alloc] init];
    _orderNumber.font = [UIFont systemFontOfSize:13];
    _orderNumber.font = [UIFont boldSystemFontOfSize:13];
    _orderNumber.textColor = [UIColor grayColor];
    _orderNumber.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderNumber];
    
    self.orderName = [[UILabel alloc] init];
    _orderName.font = [UIFont systemFontOfSize:12];
    _orderName.numberOfLines = 0;
    [self.contentView addSubview:_orderName];
    
    self.orderColorSize = [[UILabel alloc] init];
    _orderColorSize.font = [UIFont systemFontOfSize:12];
    _orderColorSize.numberOfLines = 0;
    _orderColorSize.textColor = [UIColor grayColor];
    [self.contentView addSubview:_orderColorSize];
    
    
    
    
    CGFloat Margin = 10;
    CGFloat leftM = 15;
    
    CGFloat cellHeight;
    if (iPhone5) {
        cellHeight =  HEIGHT/6;
    }else if (iPhone6){
        cellHeight =  HEIGHT/7;
    }else{
        cellHeight=  HEIGHT/7;
    }
    
    [_orderImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).offset(leftM);
        make.width.height.mas_equalTo(cellHeight - leftM*2);
        make.top.equalTo(self.mas_top).offset(leftM);
    }];
    
    [_orderPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.mas_right).offset(-Margin);
        make.top.equalTo(_orderImg.mas_top).offset(2);
        make.width.mas_equalTo(60);
    }];
    
    [_orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.mas_right).offset(-Margin);
        make.top.equalTo(_orderColorSize.mas_top);
    }];
    
    
    
    
    [_orderName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_orderImg.mas_right).offset(Margin);
        make.top.equalTo(_orderImg.mas_top).offset(2);
        make.width.mas_equalTo(WIDTH- (cellHeight - 30) - 100);
    }];
    
    
    [_orderColorSize mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_orderName.mas_left);
        make.top.equalTo(_orderName.mas_bottom).offset(5);
        make.width.equalTo(_orderName.mas_width);
    }];
}

@end
